/**
 业主详情页面
 **/
(function (vc) {
    vc.extends({
        data: {
            affiliateUserInfo: {
                auId: '',
                ruleId: '',
                ruleName: '',
                userId: '',
                userName: '',
                level: '',
                state: '',
                totalCommission: '',
                availableCommission: '',
                withdrawnCommission:'',
                teamCount:'',
                _currentTab: 'detailAffiliateUser',
            }
        },
        _initMethod: function () {
            $that.affiliateUserInfo.auId = vc.getParam('auId');
            if (!vc.notNull($that.affiliateUserInfo.auId)) {
                return;
            }
            $that._listDetail();

        },
        _initEvent: function () {
            vc.on('detailAffiliater', 'listData', function (_info) {
                $that.changeTab($that.affiliateUserInfo._currentTab);
            });
        },
        methods: {
            _listDetail: function (_page, _rows) {

                let param = {
                    params: {
                        page:1,
                        row:1,
                        auId:$that.affiliateUserInfo.auId
                    }
                };

                //发送get请求
                vc.http.apiGet('/affiliateUser.listAffiliateUser',
                    param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        vc.copyObject(_json.data[0],$that.affiliateUserInfo);
                        $that.changeTab($that.affiliateUserInfo._currentTab);

                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            changeTab: function (_tab) {
                $that.affiliateUserInfo._currentTab = _tab;

                vc.emit(_tab, 'switch', {
                    auId: $that.affiliateUserInfo.auId,
                });
            },
            _level: function (_state) {
                if(_state == "1"){
                    return "一级"
                }
                if(_state == "2"){
                    return "二级"
                }
            },
            _auditState: function (_state) {
                if(_state == "0"){
                    return "待审核"
                }
                if(_state == "1"){
                    return "审核通过"
                }
                if(_state == "2"){
                    return "已拒绝"
                }
            },
        }
    });
})(window.vc);
